<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我好想种棵树啊 </title>
    <style>
        /* 全局样式 */
        body {
            background: #1a2f38;
            display: flex;
            flex-direction: column;
            align-items: center;
            font-family: 'Courier New', monospace;
            margin: 0;
            padding: 0;
            min-height: 100vh;
            overflow-x: hidden;
            color: #c3d8df;
        }

        header {
            margin-top: 20px;
            text-align: center;
            padding: 10px;
            width: 100%;
        }

        h1 {
            color: #3c887e;
            font-size: 28px;
            text-shadow: 0 0 5px rgba(60, 136, 126, 0.5);
        }

        /* 诗歌容器 */
        .poem {
            color: #c3d8df;
            max-width: 600px;
            margin: 40px;
            line-height: 1.8;
            border-left: 3px solid #3c887e;
            padding-left: 20px;
            transition: transform 0.3s ease;
        }

        .poem:hover {
            transform: translateX(5px);
        }

        .poem h2 {
            color: #6ba08a;
        }

        /* 代码树 */
        .code-tree {
            position: relative;
            margin: 50px;
            height: 300px;
            width: 300px;
            transition: all 0.5s ease;
        }

        .code-tree:hover {
            transform: scale(1.05);
        }

        /* 树干 */
        .trunk {
            position: absolute;
            width: 20px;
            height: 150px;
            background: #785549;
            bottom: 0;
            left: 50%;
            transform: translateX(-50%);
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
            transition: height 2s ease;
        }

        /* 树冠 */
        .canopy {
            position: absolute;
            width: 120px;
            height: 100px;
            background: #2c5a47;
            bottom: 140px;
            left: 50%;
            transform: translateX(-50%);
            border-radius: 50px;
            box-shadow: 
                0 0 10px #3c887e,
                inset 0 0 20px #1d4037;
            animation: pulse 3s infinite alternate;
            transition: all 1s ease;
        }

        @keyframes pulse {
            0% {
                box-shadow: 0 0 10px #3c887e, inset 0 0 20px #1d4037;
            }
            100% {
                box-shadow: 0 0 20px #3c887e, inset 0 0 30px #1d4037;
            }
        }

        /* 第二层树冠 */
        .canopy-2 {
            position: absolute;
            width: 150px;
            height: 120px;
            background: #2c5a47;
            bottom: 100px;
            left: 50%;
            transform: translateX(-50%);
            border-radius: 60px;
            box-shadow: 
                0 0 10px #3c887e,
                inset 0 0 20px #1d4037;
            animation: pulse 4s infinite alternate;
            z-index: -1;
        }

        /* 树下的土壤 */
        .ground {
            position: absolute;
            width: 100px;
            height: 20px;
            background: #5d4037;
            bottom: -10px;
            left: 50%;
            transform: translateX(-50%);
            border-radius: 50%;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
        }

        /* 代码装饰 */
        .code {
            position: absolute;
            color: #6ba08a;
            font-size: 12px;
            white-space: nowrap;
            transition: all 0.3s ease;
        }

        .code:hover {
            color: #8ecbaf;
            transform: translateY(-2px);
            text-shadow: 0 0 5px rgba(60, 136, 126, 0.7);
        }

        .code::before {
            content: "// ";
            color: #4d7069;
        }

        /* 叶子 */
        .leaf {
            position: absolute;
            width: 10px;
            height: 10px;
            background: #4caf50;
            border-radius: 50%;
            animation: float 5s infinite alternate ease-in-out;
            opacity: 0;
        }

        @keyframes float {
            0% {
                transform: translate(0, 0) rotate(0deg);
            }
            100% {
                transform: translate(10px, 10px) rotate(45deg);
            }
        }

        /* 添加点击交互效果区域 */
        .interactive-area {
            position: absolute;
            width: 300px;
            height: 300px;
            cursor: pointer;
            z-index: 10;
        }

        /* 页脚 */
        footer {
            margin-top: 50px;
            margin-bottom: 20px;
            font-size: 14px;
            color: #4d7069;
            text-align: center;
            width: 100%;
        }

        /* 王笑言的树标签 */
        .tree-owner {
            color: #6ba08a;
            font-weight: bold;
            padding: 0 5px;
            border-bottom: 1px dashed #3c887e;
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .poem {
                margin: 20px;
                font-size: 14px;
            }
            
            .code-tree {
                margin: 30px;
                height: 250px;
            }
        }

        /* 代码雨 */
        .rain-container {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: -2;
        }

        .code-rain {
            position: absolute;
            color: #3c887e;
            font-family: 'Courier New', monospace;
            font-size: 14px;
            opacity: 0.3;
            animation: rain linear infinite;
        }

        @keyframes rain {
            0% {
                transform: translateY(-100px);
                opacity: 0;
            }
            10% {
                opacity: 0.3;
            }
            90% {
                opacity: 0.3;
            }
            100% {
                transform: translateY(100vh);
                opacity: 0;
            }
        }
    </style>
</head>
<body>
    <header>
        <h1>我好想种棵树啊</h1>
    </header>

    <div class="code-tree">
        <div class="interactive-area" id="tree-clicker"></div>
        <div class="ground"></div>
        <div class="trunk" id="trunk"></div>
        <div class="canopy-2"></div>
        <div class="canopy" id="canopy"></div>
        <div class="code" style="top:30px; left:-40px;">if (tree.isGrowing()) {</div>
        <div class="code" style="top:50px; left:120px;">console.log("绿色未来");</div>
        <div class="code" style="top:80px; right:-50px;">branch++;</div>
        <div class="code" style="top:120px; right:30px;">}</div>
        <div class="code" style="top:150px; left:10px;">// 年轮.add()</div>
        <div class="code" style="top:180px; left:-30px;">const promise = tree.grow();</div>
        <div class="code" style="top:210px; right:-60px;">// 生态系统.sustain()</div>
    </div>

    <div class="poem">
        <h2>《森林的布尔值》</h2>
        <p>by 网上抄的小湿</p>
        <pre>
键盘叩击的间隙
一粒粒字符正在发芽
我调试着循环里的年轮
直到指针在树冠间溢出月光

bug是误入的甲虫
蜷缩在某个叶片的背面
而我的注释如护林员
用括号加固每截脆弱的枝干

当风穿过if-else的缝隙
整片森林沙沙作响
光标闪烁的铁锹下
新绿正以十六进制生长

最后一次commit时
露珠从枝头滚落
整个春天突然return了
一行湿润的true
        </pre>
    </div>

    <footer>
        &copy;  <span class="tree-owner">王笑言的树</span> 
    </footer>

    <div class="rain-container" id="rain-container"></div>

    <script>
        // 点击树木的交互
        const treeClicker = document.getElementById('tree-clicker');
        const trunk = document.getElementById('trunk');
        const canopy = document.getElementById('canopy');
        const rainContainer = document.getElementById('rain-container');
        const treeCountElement = document.getElementById('tree-count');
        
        let treeCount = 0;
        let clickCount = 0;
        
        // 创建代码雨
        function createCodeRain() {
            const codeChars = '01{}[]()<>=+-*/let const function if else return true false;';
            const rainDrops = 25;
            
            for (let i = 0; i < rainDrops; i++) {
                const drop = document.createElement('div');
                drop.className = 'code-rain';
                drop.style.left = Math.random() * 100 + 'vw';
                drop.style.animationDuration = 3 + Math.random() * 7 + 's';
                drop.textContent = codeChars[Math.floor(Math.random() * codeChars.length)];
                drop.style.opacity = 0.1 + Math.random() * 0.3;
                rainContainer.appendChild(drop);
            }
        }

        // 创建叶子
        function createLeaf() {
            const leaf = document.createElement('div');
            leaf.className = 'leaf';
            
            // 随机位置
            const angle = Math.random() * Math.PI * 2;
            const distance = 30 + Math.random() * 50;
            const x = Math.cos(angle) * distance;
            const y = Math.sin(angle) * distance - 100;
            
            leaf.style.left = `calc(50% + ${x}px)`;
            leaf.style.bottom = `calc(140px + ${-y}px)`;
            leaf.style.backgroundColor = `hsl(${110 + Math.random() * 40}, ${70 + Math.random() * 30}%, ${40 + Math.random() * 20}%)`;
            leaf.style.animationDelay = `${Math.random() * 2}s`;
            leaf.style.animationDuration = `${3 + Math.random() * 4}s`;
            
            document.querySelector('.code-tree').appendChild(leaf);
            
            // 让叶子慢慢出现
            setTimeout(() => {
                leaf.style.opacity = 0.7 + Math.random() * 0.3;
            }, 100);
            
            // 一段时间后移除叶子
            setTimeout(() => {
                leaf.style.opacity = '0';
                setTimeout(() => {
                    leaf.remove();
                }, 1000);
            }, 10000 + Math.random() * 5000);
        }

        // 点击树木增加点数
        treeClicker.addEventListener('click', () => {
            clickCount++;
            
            // 每点击5次增加树高
            if (clickCount % 5 === 0) {
                const currentHeight = parseInt(getComputedStyle(trunk).height);
                trunk.style.height = `${currentHeight + 10}px`;
                canopy.style.bottom = `${currentHeight + 10 - 10}px`;
            }
            
            // 增加叶子
            for (let i = 0; i < 3; i++) {
                createLeaf();
            }
            
            // 每点击10次增加一棵树计数
            if (clickCount % 10 === 0) {
                treeCount++;
                treeCountElement.textContent = treeCount;
                
                // 如果是10的倍数，添加一个特殊动画
                canopy.style.transform = 'translateX(-50%) scale(1.2)';
                setTimeout(() => {
                    canopy.style.transform = 'translateX(-50%) scale(1)';
                }, 300);
            }
        });
        
        // 初始化代码雨
        createCodeRain();
        
        // 每隔一段时间刷新代码雨
        setInterval(() => {
            rainContainer.innerHTML = '';
            createCodeRain();
        }, 10000);
        
        // 初始时添加一些叶子
        for (let i = 0; i < 10; i++) {
            setTimeout(() => {
                createLeaf();
            }, i * 300);
        }
    </script>
</body>
</html>
